package com.example.plumneedle.Framgment;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.plumneedle.R;
import com.wyt.searchbox.SearchFragment;
import com.wyt.searchbox.custom.IOnSearchClickListener;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

public class BlankFragment1 extends Fragment {
    private EditText editText;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_blank1, container, false);
    }

    public void onActivityCreated(@Nullable Bundle saveInstanceState){
        super.onActivityCreated(saveInstanceState);
        JCVideoPlayerStandard jcVideoPlayerStandard = getActivity().findViewById(R.id.videoPlayer);
        jcVideoPlayerStandard.setUp("http://flashmedia.eastday.com/newdate/news/2016-11/shznews1125-19.mp4", JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
        // jcVideoPlayerStandard.thumbImageView.setImageURI(Uri.parse("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640"));
        Glide.with(this).load("https://pic.rmb.bdstatic.com/bjh/a5664fe9d251b6b0d2f35c0472533904.jpeg@s_2,w_681,h_381,q_100,f_webp").into(jcVideoPlayerStandard.thumbImageView);
        JCVideoPlayerStandard jcVideoPlayerStandard1 = getActivity().findViewById(R.id.videoPlayer1);
        jcVideoPlayerStandard1.setUp("http://flashmedia.eastday.com/newdate/news/2016-11/shznews1125-19.mp4", JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
        // jcVideoPlayerStandard.thumbImageView.setImageURI(Uri.parse("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640"));
        Glide.with(this).load("https://pic.rmb.bdstatic.com/bjh/a5664fe9d251b6b0d2f35c0472533904.jpeg@s_2,w_681,h_381,q_100,f_webp").into(jcVideoPlayerStandard1.thumbImageView);
        editText=getActivity().findViewById(R.id.editText1);
        final SearchFragment searchFragment = SearchFragment.newInstance();
        searchFragment.setOnSearchClickListener(new IOnSearchClickListener() {
            @Override
            public void OnSearchClick(String keyword) {
                //这里处理逻辑
                Toast.makeText(getContext(), keyword, Toast.LENGTH_SHORT).show();
            }
        });
        editText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                searchFragment.showFragment(getActivity().getSupportFragmentManager(),SearchFragment.TAG);
            }
        });
    }
    @Override
    public void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }
}
